package com.coco.expressfee.controller;

import com.coco.common.annotation.IngoreResponseAdvice;
import com.coco.common.result.CommonResponse;
import com.coco.expressfee.pojo.TbPostage;
import com.coco.expressfee.service.ExpressFeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * controller
 * @Author: guofeng
 * @Date: 2021/07/14/20:46
 * @Description:
 */

@RestController
@RequestMapping("/expressfee")
public class ExpressFeeController {

    @Autowired
    private ExpressFeeService expressFeeService;

    /**
     * 增加
     * @param postage
     * @return
     */
    @RequestMapping("/add")
    public void add(@RequestBody TbPostage postage){
        expressFeeService.add(postage);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @RequestMapping("/delete")
    public void delete(Long [] ids){
        expressFeeService.delete(ids);
    }

    /**
     * 修改
     * @param goods
     * @return
     */
    @RequestMapping("/update")
    public void update(@RequestBody TbPostage goods){
        expressFeeService.update(goods);
    }

    /**
     * 获取实体
     * @param id
     * @return
     */
    @RequestMapping("/findOne/{id}")
    public TbPostage findOne(@PathVariable Long id){
       return expressFeeService.findOne(id);
    }

    /**
     * 返回全部列表
     * @return
     */
    @RequestMapping("/findAll")
    public List<TbPostage> findAll(){
       return expressFeeService.findAll();
    }


    /**
     * 返回全部列表带条件
     * @return
     */
    @RequestMapping("/findAllSearch")
    public List<TbPostage> findAll(@RequestBody TbPostage goods){
        return expressFeeService.findAll(goods);
    }

    /**
     * 查询+分页
     * @param
     * @return
     */
    @RequestMapping("/search")
    public List<TbPostage> search(@RequestBody TbPostage tbPostage){
       return expressFeeService.findAllSearch(tbPostage);
    }

    /**
     * 根据商品id查询运费模板
     */
    @IngoreResponseAdvice
    @GetMapping("/findByGid/{gid}")
    public List<TbPostage> findByGid(@PathVariable("gid") String gid){
        return expressFeeService.findByGid(gid);
    }

    @DeleteMapping("/deleteByGid/{gid}")
    public void deleteByGid(@PathVariable("gid") String gid){
        expressFeeService.deleteByGid(gid);
    }

}



